/*
** readdir.c for tp in /home/comet_a/afs/local/sys_unix/my_ls/tp_opendir_readdir
** 
** Made by alexandre comet
** Login   <comet_a@epitech.net>
** 
** Started on  Wed Nov 30 16:57:26 2011 alexandre comet
** Last update Mon Oct 29 14:44:14 2012 thomas nadalie
*/
#include        <stdlib.h>
#include        <stdio.h>
#include        <sys/types.h>
#include        <dirent.h>
#include        <sys/stat.h>
#include        <unistd.h>
#include	"my_ls.h"

int		main(int ac, char **av)
{
  DIR		*rtr;
  struct dirent	*d;
  char		*name;

  name = av[1];
  rtr = opendir(name);
  if (rtr == NULL)
    exit (0);
  d = readdir(rtr);
  if (d == NULL)
    exit (0);
  my_putstr(d->d_name);
  my_putchar('\n');
  while (d != 0)
    {
      d = readdir(rtr);
      if (d == NULL)
	exit (0);
      my_putstr(d->d_name);
      my_putchar('\n');
    }
  return (0);
}
